package com.huawei.appmarket.framework.widget;

import android.graphics.Canvas;
import android.graphics.Paint;
import android.graphics.Paint.FontMetricsInt;
import android.text.style.ReplacementSpan;
import android.widget.TextView;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import java.lang.ref.WeakReference;

class TagRenderTextView$c extends ReplacementSpan {
    private WeakReference<TextView> ˋ;
    private int ˏ;
    private int ॱ;

    public TagRenderTextView$c(TextView textView) {
        this.ˋ = new WeakReference(textView);
        if (textView != null) {
            textView.measure(0, 0);
            this.ˏ = textView.getMeasuredWidth();
            this.ॱ = textView.getMeasuredHeight();
        }
    }

    public int getSize(@NonNull Paint paint, CharSequence charSequence, int i, int i2, @Nullable FontMetricsInt fontMetricsInt) {
        if (fontMetricsInt != null) {
            FontMetricsInt fontMetricsInt2 = paint.getFontMetricsInt();
            fontMetricsInt.ascent = fontMetricsInt2.top;
            fontMetricsInt.top = fontMetricsInt2.top;
            fontMetricsInt.descent = fontMetricsInt2.descent;
            fontMetricsInt.bottom = fontMetricsInt2.bottom;
        }
        return this.ˏ;
    }

    public void draw(@NonNull Canvas canvas, CharSequence charSequence, int i, int i2, float f, int i3, int i4, int i5, @NonNull Paint paint) {
        TextView textView = (TextView) this.ˋ.get();
        if (textView != null) {
            FontMetricsInt fontMetricsInt = paint.getFontMetricsInt();
            int i6 = ((fontMetricsInt.ascent + ((fontMetricsInt.descent + i4) + i4)) / 2) - (this.ॱ / 2);
            canvas.save();
            canvas.translate(f, (float) i6);
            textView.layout(0, 0, this.ˏ, this.ॱ);
            textView.draw(canvas);
            canvas.restore();
        }
    }
}
